import {defineStore} from "pinia";
import {ref} from "vue";

export const useOrderDetailsStore = defineStore('orderDetails', () => {
    //用户id,token
    const orderDetails = ref({})
    const order = ref({})
    const addOrderDetailsById = (id, data) => orderDetails.value[id] = data;
    const getOrderDetailsById = id => orderDetails.value[id];
    const removeOrderDetailsById = id => orderDetails.value[id] = undefined;
    //重置数据
    const reset = () => {
        orderDetails.value = []
        localStorage.clear()
    }
    return {
        orderDetails, order,
        addOrderDetailsById,
        getOrderDetailsById,
        removeOrderDetailsById,
        reset
    }
}, {
    persist: true
})